//
//var min = 0;
//var hour = 0;
//function stopwatch(text) {
//    var sec = parseInt(document.clock.stwa.value);
//    sec++;
//
//    document.clock.stwa.value = sec;
//
//    if (text == "Start") {
//        document.clock.theButton.value = "Stop ";
//    }
//    if (text == "Stop ") {
//        document.clock.theButton.value = "Start";
//    }
//
//    if (document.clock.theButton.value == "Start") {
//        window.clearTimeout(SD);
//        return true;
//    }
//    SD=window.setTimeout("stopwatch();", 1000);
//}
//
//function resetIt() {
//    sec = -1;
//    min = 0;
//    hour = 0;
//    confirm("Are you sure want to reset the Timer ?")
//    if (document.clock.theButton.value == "Stop ") {
//        document.clock.theButton.value = "Start";
//    }
//    window.clearTimeout(SD);
//}
//



jQuery.noConflict();
var sec = 0;
var min = 0;
var hour = 0;

function stopwatch(text) {
    sec++;
    if (sec == 60) {
        sec = 0;
        min = min + 1;
    }
    else {
        min = min;
    }
    if (min == 60) {
        min = 0;
        hour += 1;
    }
    if(hour == 24){
        alert("You have reached to the end of the day..Would you like to start a new timer...?");
        resetIt();

    }

    if (sec<=9) {
        sec = "0" + sec;
    }
    document.clock.stwa.value = ((hour<=9) ? "0"+hour : hour) + ":" + ((min<=9) ? "0" + min : min) + ":" + sec;

    if (text == "Start") {
        document.clock.theButton.value = "Started";
        document.clock.theButton.disabled=true;
        document.clock.theButton1.disabled=false;
    }
    if (text == "Stop") {
        document.clock.theButton.value = "Start";
    }

    if (document.clock.theButton.value == "Start") {
        window.clearTimeout(SD);
        return true;
    }
    SD=window.setTimeout("stopwatch();", 1000);
}

function stopwatch1(text) {
    if (text == "Pause") {
        document.clock.theButton.disabled=false;
        document.clock.theButton.value = "Start";
        document.clock.theButton1.disabled=true;
    }

}

function resetIt() {
    alert("Are you sure want to reset the Timer ?");
    sec = 0;
    min = 0;
    hour = 0;
    document.clock.stwa.value="00:00:00";
    if (document.clock.theButton.value == "Stop ") {
        document.clock.theButton.value = "Start";
    }
    window.clearTimeout(SD);
}